<?php

namespace app\api\model;

use think\Model;

class CharitableClass extends Model
{
    protected $name = 'charitable_class';
    /**
     * 查询所有文章分类
     * @param $language 语言
     * @return CharitableArticle[]|array|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getList($language){
        $file = 'id';
        $file .= ','.file_language('title',$language);
        $file .= ','.file_language('pic',$language);
        return self::field($file)->select();
    }

    /**
     * 获取分类详情
     * @param $id   分类ID
     * @param $language 语言
     * @return CharitableClass|array|mixed|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getDetails($id,$language){
        $file = 'id';
        $file .= ','.file_language('title',$language);
        $file .= ','.file_language('pic',$language);
        return self::where('id',$id)->field($file)->find();
    }

}